package cn.wk.org.controller;

import cn.wk.basic.utils.AjaxResult;
import cn.wk.org.domain.Shop;
import cn.wk.org.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/audit")
public class AuditController {
    @Autowired
    private IShopService shopService;
    @PostMapping
    public List<Shop> toAudit(){
        return shopService.toAudit();
    }

    /**
     * 审核通过
     * @param shop
     * @return
     */
    @PutMapping
    public AjaxResult updateState(@RequestBody Shop shop){
        System.out.println(shop.getId());
        try{
            shopService.updateState(shop.getId());
            return new AjaxResult();
        }catch(Exception e){
            e.printStackTrace();
            return new AjaxResult("通过失败");
        }
    }
}
